package com.quanquan.store.controller.statisticsReport;

import com.quanquan.store.request.CouponCodeRequest;
import com.quanquan.store.request.CouponRequest;
import com.quanquan.store.service.statisticsReport.CouponReportService;
import enums.ResCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import web.response.ResultBody;

import java.io.Serializable;
import java.util.Map;

/**
 * 功能描述:优惠券统计报表
 *
 * @ClassName: CouponReportController
 * @Author: xiongjunbao
 * @Date: 2019-05-30 10:31
 * @Version: V1.0
 */
@RestController
@RequestMapping("/coupon_num")
public class CouponReportController implements Serializable {
    private final CouponReportService couponReportService;

    @Autowired
    public CouponReportController(CouponReportService couponReportService) {
        this.couponReportService = couponReportService;
    }


    /**
     * 优惠券领取总量统计 分日、周、月、年
     *
     * @return
     */
    @PostMapping("/coupon_add_num")
    public ResultBody couponAddNum(@RequestBody CouponCodeRequest request) {
        //获取当前时间
        Map<String, Object> map = couponReportService.couponAddNum(request);
        if (map.isEmpty()){
            return new ResultBody(ResCodeEnum.NO_DATA.getCode(), "暂无数据");
        }
        return new ResultBody(ResCodeEnum.SUCCESS.getCode(), "SUCCESS",map);
    }

    /**
     * 优惠券使用总量统计 分日、周、月、年
     *
     * @return
     */
    @PostMapping("/coupon_use_num")
    public ResultBody couponUseNum(@RequestBody CouponRequest request) {
        // 统计周期 日 dality  周 week 月 month 年 year
        Map<String, Object> map = couponReportService.couponUseNum(request);
        if (map.isEmpty()){
            return new ResultBody(ResCodeEnum.NO_DATA.getCode(), "暂无数据");
        }
        return new ResultBody(ResCodeEnum.SUCCESS.getCode(), "SUCCESS",map);
    }

    /**
     * 停车券领取总量统计 分日、周、月、年
     *
     * @return
     */
    @PostMapping("/parking_coupon_add_num")
    public ResultBody parkingCouponAddNum(@RequestBody CouponCodeRequest request) {
        //获取当前时间
        Map<String, Object> map = couponReportService.parkingCouponAddNum(request);
        if (map.isEmpty()){
            return new ResultBody(ResCodeEnum.NO_DATA.getCode(), "暂无数据");
        }
        return new ResultBody(ResCodeEnum.SUCCESS.getCode(), "SUCCESS",map);
    }

    /**
     * 停车券使用总量统计 分日、周、月、年
     *
     * @return
     */
    @PostMapping("/parking_coupon_use_num")
    public ResultBody parkingCouponUseNum(@RequestBody CouponRequest request) {
        // 统计周期 日 dality  周 week 月 month 年 year
        Map<String, Object> map = couponReportService.parkingCouponUseNum(request);
        if (map.isEmpty()){
            return new ResultBody(ResCodeEnum.NO_DATA.getCode(), "暂无数据");
        }
        return new ResultBody(ResCodeEnum.SUCCESS.getCode(), "SUCCESS",map);
    }


}
